//
//  SecutyViewController.m
//  penzer
//
//  Created by caiyc on 2018/10/17.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "SecutyViewController.h"
#import "ResetPassViewController.h"
#import "LivenessViewController.h"
#import "DetectionViewController.h"
#import <IDLFaceSDK/FaceSDKManager.h>

#import "LivingConfigModel.h"
@interface SecutyViewController ()

@end

@implementation SecutyViewController
- (IBAction)func_Action:(UIButton *)sender {
    if(sender.tag==1){
        ResetPassViewController *vc = [[ResetPassViewController alloc]init];
        [self pushSecondVC:vc];
    }else{
        LivenessViewController* lvc = [[LivenessViewController alloc] init];
        LivingConfigModel* model = [LivingConfigModel sharedInstance];
        NSArray *arr = @[@(FaceLivenessActionTypeLiveEye)];
        model.isByOrder = YES;
        [model.liveActionArray addObjectsFromArray:arr];
        [lvc livenesswithList:model.liveActionArray order:model.isByOrder numberOfLiveness:model.numOfLiveness];
        lvc.completion=^(NSDictionary *images, UIImage *originImage){
            if([images[@"bestImage"] count] > 0){
                NSData* data = [[NSData alloc] initWithBase64EncodedString:[images[@"bestImage"] lastObject] options:NSDataBase64DecodingIgnoreUnknownCharacters];
                NSString *base_Str = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
              [self uploadFace:base_Str];
                }
        };
        [self pushSecondVC:lvc];

    }
}
-(void)uploadFace:(NSString *)base64{
   
        NSDictionary *param = @{@"image":base64,@"ta":@"face_add",@"op":@"member",@"ctrl":@"live",@"ac":@"member"};
        [self weqPostHandle:param success:^(id response) {
            if(response){
                [WToast showWithText:@"人脸设置成功"];
               // self.hasface = 1;
            }
        } failure:^(NSError *error) {
            
        }];
   
}
- (void)viewDidLoad {
    [super viewDidLoad];
     [self setNavigation:1 andTitle:@"安全中心" andNaviColor:[UIColor whiteColor] andTitleColor:nil];
    // Do any additional setup after loading the view from its nib.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
